/*
 * @Description: 
 * @Autor: 商晓彬
 * @Date: 2021-12-05 12:44:20
 * @LastEditors: 商晓彬
 * @LastEditTime: 2021-12-23 10:44:10
 */
import { AfterViewChecked, Component, ElementRef, EventEmitter, Injector, Input, Output, ViewChild } from '@angular/core';
import { AppComponentBase } from '@shared/common/app-component-base';
import { ModalDirective } from 'ngx-bootstrap';
import { MessageService } from '@abp/message/message.service';
import { finalize } from 'rxjs/operators';
import { Table } from 'primeng/components/table/table';
import { Paginator } from 'primeng/components/paginator/paginator';
import { LazyLoadEvent } from 'primeng/api';
import { AssemblyProgressBoardServiceProxy } from '@shared/service-proxies/service-proxies';

@Component({
    selector: 'app-assembly-inner',
    templateUrl: './assembly-inner.component.html',
    styleUrls: ['./assembly-inner.component.less']
})
export class AssemblyInnerComponent extends AppComponentBase {
    //引入子组件
    @ViewChild('createOrEditModal') modal: ModalDirective;
    @Input() editData: any;  //行数据
    saving = false;
    rowData = [];
    btName = undefined;
    btWorkHour = undefined;
    btWorkSum = undefined;
    selectBt = undefined;
    selectBtOptions = [];
    constructor(
        injector: Injector,
        private _messageService: MessageService,
        private _assemblyProgressBoardServiceProxy: AssemblyProgressBoardServiceProxy,
    ) {
        super(injector);
    }
    getTableList() {
        this._assemblyProgressBoardServiceProxy.getBTTaskListForBoard(
            this.editData.id,
            this.selectBt
        ).pipe(finalize(() => { }))
            .subscribe(result => {
                this.selectBt = result.btId;
                this.btName = result.name;
                this.btWorkHour = result.taskHour;
                this.btWorkSum = result.taskCount;
                this.rowData = result.techniqueEntityDatas;
            });
    }
    ngOnInit() {
    }
    onShown(): void {
        this.getTableList();
        this._assemblyProgressBoardServiceProxy.getBTDropList(
            this.editData.id,
        ).pipe(finalize(() => { }))
            .subscribe(result => {
                this.selectBtOptions = result;
            });
    }
    resert() {
        this.selectBt = undefined;
    }
    show(): void {
        this.modal.show();
    }
    //关闭事件
    close(): void {
        this.selectBtOptions = [];
        this.selectBt = undefined;
        this.btName = undefined;
        this.btWorkHour = undefined;
        this.btWorkSum = undefined;
        this.rowData = [];
        this.modal.hide();
    }

}
